package com.ld.collegetask.beans;

import android.databinding.BindingAdapter;
import android.view.View;
import android.widget.ImageView;

import com.ld.collegetask.R;
import com.squareup.picasso.Picasso;

/**
 * Created by 樊海波 on 2017/10/18.
 */

public class ReleaseDiscountBean {
    /**
     * dbegindate : 2018-01-25 09:41:47.0
     * denddate : 2018-02-04 09:41:54.0
     * dcreatedate : 2018-01-31 09:41:58.0
     * minconsume : 3
     * dname : 1
     * dstatus : 0
     * discountId : 4
     * discount : 1
     */

    private String dbegindate;
    private String denddate;
    private String dcreatedate;
    private String minconsume;
    private String dname;
    private int dstatus;
    private int discountId;
    private String discount;
    private int bool;

    public int isBool() {
        return bool;
    }

    public void setBool(int bool) {
        this.bool = bool;
    }

    public int getVisible() {
        if (bool == 0){
            if (dstatus == 0){
                return View.VISIBLE;
            }else {
                return View.GONE;
            }
        }else {
            if (dstatus == 0){
                return View.GONE;
            }else {
                return View.VISIBLE;
            }
        }
    }

    public int getDiscount_img_1() {
        if (dstatus == 0) {
            return R.drawable.discount_1;
        } else {
            return R.drawable.discount_1_no;
        }
    }

    public int getDiscount_img() {
        if (dstatus == 0) {
            return R.drawable.discount;
        } else {
            return R.drawable.discount_no;
        }
    }

    public String getMinconsume() {
        return minconsume;
    }

    public void setMinconsume(String minconsume) {
        this.minconsume = minconsume;
    }

    @BindingAdapter({"bind:titleImg"})
// xml的ImageView里面这样调用：app:titleImg="@{courseListBean.titleImg}"
    public static void loadImage(ImageView view, int imageUrl) {
        Picasso.with(view.getContext())
                .load(imageUrl)
//                .placeholder(R.drawable.placeholder)
                .into(view);
    }

    public String getDbegindate() {
        return dbegindate;
    }

    public void setDbegindate(String dbegindate) {
        this.dbegindate = dbegindate;
    }

    public String getDenddate() {
        return denddate;
    }

    public void setDenddate(String denddate) {
        this.denddate = denddate;
    }

    public String getDcreatedate() {
        return dcreatedate;
    }

    public void setDcreatedate(String dcreatedate) {
        this.dcreatedate = dcreatedate;
    }

    public String getDname() {
        return dname;
    }

    public void setDname(String dname) {
        this.dname = dname;
    }

    public int getDstatus() {
        return dstatus;
    }

    public void setDstatus(int dstatus) {
        this.dstatus = dstatus;
    }

    public int getDiscountId() {
        return discountId;
    }

    public void setDiscountId(int discountId) {
        this.discountId = discountId;
    }

    public String getDiscount() {
        return discount;
    }

    public void setDiscount(String discount) {
        this.discount = discount;
    }

    public String getDenddate_1() {
        if (denddate == null || denddate.equals(""))
            return "有效时间至:长期";
        return "有效时间至:" + denddate.split(" ")[0];
    }

    public String getDname_1() {
        return dname + "元优惠卷";
    }

    public String getMinconsume_1() {
        return "佣金超过"+minconsume+"元可用";
    }
}
